package routes

import (
	"noword/auth"
	"noword/handle"

	"github.com/gin-gonic/gin"
)

// SetupRoutes 设置路由
func SetupRoutes(backupDir string, router *gin.Engine) {
	// 公开路由 - 登录获取Token
	router.POST("/login", auth.LoginHandler)

	// 需要认证的路由组
	authGroup := router.Group("/")
	authGroup.Use(auth.JWTMiddleware())
	{
		authGroup.GET("/backups", func(c *gin.Context) {
			handle.ListBackupFiles(backupDir, c)
		})
		authGroup.GET("/backups/:filename", func(c *gin.Context) {
			handle.DownloadBackupFile(backupDir, c)
		})
	}
}
